Skip to content

fix: return infinity when no A* path exists - #159

Merged
shima004 merged 1 commit into
adf-python:mainfrom
ToB213:fix/158-a-star-unreachable-distance
Sep 27, 2026
Merged

shima004 merged 1 commit into
adf-python:mainfrom
ToB213:fix/158-a-star-unreachable-distance

Conversation

@ToB213

@ToB213 ToB213 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix AStarPathPlanning.get_distance() to return float("inf") when no path exists.

Previously, an unreachable destination returned 0.0 because the distance was calculated from an empty path. This made it indistinguishable from a valid zero-distance path where the source and destination are the same.

Changes

  • Return float("inf") when get_path() returns an empty list
  • Preserve 0.0 for a valid path from an entity to itself

Fixes #158

@shima004

Copy link
Copy Markdown
Member

LGTM👍️

@shima004
shima004 self-requested a review September 27, 2026 06:59
@shima004
shima004 merged commit c651650 into adf-python:main Sep 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should AStarPathPlanning.get_distance() return 0.0 when no path exists?

2 participants